package com.haier.spark.project.dao.impl


import com.haier.spark.project.dao.ITaskDao
import com.haier.spark.project.domain.Task
import com.haier.spark.project.jdbc.JDBCHelper

class TaskDaoImpl extends ITaskDao{
  /**
    * 根据id获取任务
    *
    * @param id
    * @return
    */
  override def findById(id: Long): Task = {
    val sql = "select * from task where task_id = ?"
    var task = Task()

    val params:Array[Any] = Array(id)
    JDBCHelper.executeQuery(sql, params, rs => {
      while (rs.next()) {
        task = Task(rs.getLong(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(7), rs.getString(8))
      }
    })
    task
  }
}

